package com.dzt.androidframework.jsoup.detail;

import com.dzt.androidframework.jsoup.detail.bean.ImageDetailDomain;
import com.dzt.androidframework.jsoup.detail.model.DetailDataSource;
import com.dzt.androidframework.jsoup.detail.model.RemoteDetailDataSource;

import java.util.List;

/**
 * Created by M02323 on 2017/7/12.
 */

public class ImageDetailPresenter implements DetailContract.Presenter {

	private DetailContract.View detailView;
	private RemoteDetailDataSource dataSource;

	public ImageDetailPresenter(RemoteDetailDataSource dataSource, DetailContract.View view) {
		this.dataSource = dataSource;
		detailView = view;
	}

	@Override
	public void start() {

	}

	@Override
	public void getImageDetailList(String url) {
		dataSource.getImageDetail(url, new DetailDataSource.onImageDetailParseListener() {
			@Override
			public void onSuccess(List<ImageDetailDomain> imageDetailDomainList, String article) {
				detailView.GetImageDetailList(imageDetailDomainList, article);
				detailView.hideLoading();
			}

			@Override
			public void onFailed(String msg) {
				detailView.hideLoading();
				detailView.showLoadFailed();
			}
		});
		detailView.showLoading();
	}
}
